//增加图片
$('#photos').on('click', function(){
    layer.open({
        type: 1,
        title: '相片集',
        maxmin: true,
        offset: ['80px', '600px'],
        shadeClose: true, //点击遮罩关闭层
        area : ['800px' , '520px'],
        content: '<img src="image/2.jpg" alt="" weight="200px" width="200px" onclick="changePhoto(2)"><img src="image/3.jpg" alt="" weight="200px" width="200px" onclick="changePhoto(3)"><img src="image/4.jpg" alt="" weight="200px" width="200px" onclick="changePhoto(4)"><img src="image/5.jpg" alt="" weight="200px" width="200px" onclick="changePhoto(5)"><img src="image/6.jpg" alt="" weight="200px" width="200px" onclick="changePhoto(6)"><img src="image/7.jpg" alt="" weight="200px" width="200px" onclick="changePhoto(7)"><img src="image/8.jpg" alt="" weight="200px" width="200px" onclick="changePhoto(8)"><img src="image/9.jpg" alt="" weight="200px" width="200px" onclick="changePhoto(9)">'
    });
    avalon.scan()
});
//增加背景图片
$('#backgroundPhoto').on('click', function(){
    layer.open({
        type: 1,
        title: '相片集',
        offset: ['80px', '600px'],
        maxmin: true,
        shadeClose: true, //点击遮罩关闭层
        area : ['800px' , '520px'],
        content: '<img src="image/b_2.jpg" alt="" weight="200px" width="200px" onclick="changeBackgroundPhoto(2)"><img src="image/b_3.jpg" alt="" weight="200px" width="200px" onclick="changeBackgroundPhoto(3)"><img src="image/b_4.jpg" alt="" weight="200px" width="200px" onclick="changeBackgroundPhoto(4)"><img src="image/b_5.jpg" alt="" weight="200px" width="200px" onclick="changeBackgroundPhoto(5)"><img src="image/b_6.jpg" alt="" weight="200px" width="200px" onclick="changeBackgroundPhoto(6)"><img src="image/b_7.jpg" alt="" weight="200px" width="200px" onclick="changeBackgroundPhoto(7)"><img src="image/b_8.jpg" alt="" weight="200px" width="200px" onclick="changeBackgroundPhoto(8)"><img src="image/b_9.jpg" alt="" weight="200px" width="200px" onclick="changeBackgroundPhoto(9)">'
    });
    avalon.scan()
});
//平移旋转插件
$('#box').Mdrag();
//右键的使用
$('#box').on("click",".mdrag-box",function(){
  var obj=$(this);
  if(!obj.data('lockBind')){
obj.contextMenu('myMenu2', {
      //菜单样式
      menuStyle: {
        border: '2px solid white'
      },
      //菜单项样式
      itemStyle: {
        fontFamily : 'FangSong',
        backgroundColor : 'white',
        color: 'black',
        border: 'none',
        padding: '1px'

      },
      //菜单项鼠标放在上面样式
      itemHoverStyle: {
        color: 'white',
        backgroundColor: 'blue',
        border: 'none'
      },
      //事件    
      bindings: 
          {
            'item_3': function(t) {
              Delete();
            }
        }
    });
  obj.data("lockBind",'1');
}
});
//改变透明度
function ChangeOpacity(x)
{  
  index.body.opacity=x/100;
};
//改变样式
function Change1(x,type)
{   
   var type1=x.options[x.selectedIndex].text;

  index.body[type]=type1;
  
};
//改变样式
function Change2(x,type)
{  
  
  index.body[type]=x;
};

function changePhoto(e){
  var count=index._count;
  VM.Mdrag[count].body.img="image/"+e+".jpg";
};

function changeBackgroundPhoto(e){
  VM.backgroundPhoto="image/b_"+e+".jpg";
};

function Delete(){
  avalon.Array.remove(VM.Mdrag,index)
};

function mDown()
{
index.body._display="none";
};

function mUp()
{
index.body._display="block";
};

function Del(){
  index.body._flash="none";
};
//下拉菜单
$("body").on("click",".menu_head",function(){
    $(this).next(".menu_body").slideToggle(300).siblings(".menu_body").slideUp("slow");
        $(this).siblings();
});

$('.save').click(function(){

var data={
  backgroundPhoto:VM.backgroundPhoto,
  json:JSON.stringify(VM.Mdrag)
}

$.post();

});











    